#include <stdio.h>
#include <string.h>
#include <memory.h>

int main( )
{
    int t;
    scanf("%d", &t);
    while ( t-- )
    {
        char data[ 31 ];
        int k, c[ 2 ][ 26 ], i, t1, t2, j;
        memset( c, 0, sizeof( c ) );
        scanf("%s", data);
        for ( i = 0; i < strlen( data ); i++ )
            c[ 0 ][ data[ i ] - 'a' ]++;
        scanf("%s", data);
        for ( i = 0; i < strlen( data ); i++ )
            c[ 1 ][ data[ i ] - 'a' ]++;
        scanf("%d", &k);
        for ( i = 0; i < k; i++ )
        {
            t1 = i & 1;
            t2 = ( i + 1 ) & 1;
            for ( j = 0; j < 26; j++ )
                c[ t1 ][ j ] += c[ t2 ][ j ];
        }
        t1 = k & 1;
        for ( i = 0; i < 26; i++ )
        {
            printf("%c:%d\n", char( i + 'a'), c[ t1 ][ i ]);
        }
        printf("\n");
    }
    return 0;
}
